/*
*  express中间件
*   第三方中间件
*   cookie session 等中间件
*
*/

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
//使用body-parser
app.use(bodyParser.urlencoded({extended:true})); //常规数据
app.use(bodyParser.json()); //接收json数据
/*配置ejs模板引擎*/
app.set('view engine', 'ejs');

app.get('/',function (req,res) {
    res.send('你好 express');
});

app.get('/login',function (req,res) {
    res.render('form');
});

app.post('/dologin',function (req,res) {
    console.log(req.body);
    var username  = req.body.username;
    var password  = req.body.password;
    console.log(username);
    console.log(password);
    res.send(req.body);
});



app.listen(3001, 'localhost');